<?php

require_once (MLEngine . 'MakiFactory/MySQLMakis/MySQLFactory.php');
require_once (MLEngine . 'MakiFactory/Makis/BoletinMaki.php');
require_once (MLSources . 'DBConexion.php');

class MySQLBoletinMaki implements BoletinMaki {
	
	public function actualizar($boletin) {
		//se abre la conecxion :D
		$conexion = DBConexion::getConexion ();
		//se pasa los parametros en la consulta :)
		$query = sprintf ( "update boletin set fact='".$boletin->getFact()."' where codboletin = %d", $boletin->getCodboletin ());
		//se ejecuta la consulta
		return $conexion->query ( $query );
		//cerrando la conexion
		$conexion->close ();
	}
	
	public function eliminar($boletin) {	
		//se abre la conecxion :D	
		$conexion = DBConexion::getConexion ();
		//se pasa los parametros en la consulta :)
		$query = sprintf ( "delete from boletin where codboletin=%d", $boletin->getCodboletin () );
		 return $conexion->query ( $query );
		//cerrando la conexion
		$conexion->close ();
	}
	
	public function insertar($boletin) {
		//se abre la conecxion :D
		$conexion = DBConexion::getConexion ();
		//se pasa los parametros en la consulta :)
		$query = sprintf ( "insert into boletin values (null,'".$boletin->getFreg()."','".$boletin->getFact()."')" );
		//se ejecuta la consulta
		return  $conexion->query ( $query );
		//cerrando la conexion
		
		$conexion->close ();
	}
	
	public function buscar($boletin) {
		$conexion = DBConexion::getConexion ();
				
		$query = sprintf ( "select * from boletin ");
		
		$rs = $conexion->query ( $query );
						
		while ( ($row = $rs->fetch_assoc ()) != false ) {
			print ("[" . $row ["codboletin"] . " & " . $row ["freg"] . " & " . $row ["fact"] . "]</br>") ;
		} /* else {
			print ("vacio") ;
		}*/
		
		echo "num devueltas: " . $rs->num_rows;
		$rs->free ();
		
		//cerrando la conexion
		$conexion->close ();
	
	}

}

?>